{% extends "projects/project_edit_base.html" %}

{% load i18n %}

{% block title %}{% trans "Edit Subprojects" %}{% endblock %}

{% block nav-dashboard %} class="active"{% endblock %}

{% block editing-option-edit-proj %}class="active"{% endblock %}

{% block project-subprojects-active %}active{% endblock %}
{% block project_edit_content_header %}{% trans "Subprojects" %}{% endblock %}

{% block project_edit_content %}
  <p class="help_text">
    {% trans "This allows you to add subprojects to your project. This allows them to live in the same namespace in the URLConf for a subdomain or CNAME." %}
  </p>

  <h3> {% trans "Existing Subprojects" %} </h3>
  <p>
    <ul>
    {% for relationship in subprojects %}
        <li>
        <a href="{{ relationship.get_absolute_url }}">
        {{ relationship.child }}
        </a>
        (/projects/{% if relationship.alias %}{{ relationship.alias }}{% else %}{{ relationship.child.slug }}{%endif %}/)
        (<a href="{% url "projects_subprojects_delete" relationship.parent.slug relationship.child.slug %}">{% trans "Remove" %}</a>)
        </li>
    {% endfor %}
    </ul>
  <p>
    {% trans "Choose which project you would like to add as a subproject." %}
  </p>
  <form method="post" action=".">{% csrf_token %}
    {{ form.as_p }}
    <p>
      <input style="display: inline;" type="submit" value="{% trans "Submit" %}">
    </p>
  </form>
{% endblock %}


{% block footerjs %}
      $('#id_subproject').autocomplete({
    source: '{% url "search_autocomplete" %}',
    minLength: 2,
    open: function(event, ui) {
      ac_top = $('.ui-autocomplete').css('top');
      $('.ui-autocomplete').css({'width': '233px', 'top': ac_top + 10 });
    }
  });

{% endblock %}
